﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SQLite;
using APX.Enums;

namespace Classes
{
   public class Install
   {
      #region Private Member Variables

      private CorporateData account;
      private AlarmSystem alarm;
      private Customer customer;
      private DateTime date;
      private String comments;

      static private Install current;
      
      #endregion

      #region Properties

      public CorporateData Account  { get { return account; } }
      public AlarmSystem System     { get { return alarm; } }
      public Customer CustomerInfo  { get { return customer; } }
      public String Comments        { get { return comments; } }
      public String Date            { get { return date.ToString("dd MMM yyyy"); } }
      public String DBInsert
      {
         get
         {
            return String.Format("VALUES({0}, {1}, {2}, {3}, '{4}', \"{5}\")",
            account.DBString, customer.DBString, alarm.SystemDBString, alarm.SensorDBString, date.ToString("MM/dd/yyyy"), comments);
         }
      }

      #endregion

      #region Constructors
      
      /// <summary>
      /// Creates an account from a retrieved row in a SQLite database.
      /// </summary>
      /// <param name="row">The retrieved row</param>
      public Install(SQLiteDataReader row)
      {
         comments = row["Comments"] as String;
         date = DateTime.Parse(row["Installed"] as String);

         alarm = new AlarmSystem(row["System"] as String, row["Sensors"] as String);
         account = new CorporateData(row);
         customer = new Customer(row);
      }

      /// <summary>
      /// Default constructor. Should be used for debug only.
      /// </summary>
      public Install()
      {
         comments = "Default comment";
         date = DateTime.Today;

         alarm = new AlarmSystem("GoControl", "Cell", "NA", "Living Room", "1/PANIC1/None/false;2/SMK1/Hallway/false");
         account = new CorporateData("1111111", "XX000000", "Douche Bag", "None", "Digital");
         customer = new Customer("John Doe", "#1 Happy St", "Fryburg", "California", "90210", "9008675309");
      }

      #endregion
   }
}
